]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
automount: emit sounds when a drive is connected/disconnected
authorCosimo Cecchi <cosimoc@gnome.org>
Mon, 27 Jun 2011 15:51:23 +0000 (11:51 -0400)
committerCosimo Cecchi <cosimoc@gnome.org>
Wed, 13 Jul 2011 18:39:36 +0000 (14:39 -0400)
https://bugzilla.gnome.org/show_bug.cgi?id=653520

js/ui/automountManager.js

index 7a22e1d069c9d2ef3eb283b08aabeb71ac233612..a34a28f358fc6cfb1a5aa9bbcfaab1e58516a886 100644 (file)
@@ -98,6 +98,12 @@ AutomountManager.prototype = {
         this._volumeMonitor.connect('volume-removed',
                                     Lang.bind(this,
                                               this._onVolumeRemoved));
+        this._volumeMonitor.connect('drive-connected',
+                                    Lang.bind(this,
+                                              this._onDriveConnected));
+        this._volumeMonitor.connect('drive-disconnected',
+                                    Lang.bind(this,
+                                              this._onDriveDisconnected));
 
         Mainloop.idle_add(Lang.bind(this, this._startupMountAll));
     },
@@ -123,6 +129,30 @@ AutomountManager.prototype = {
         return false;
     },
 
+    _onDriveConnected: function() {
+        // if we're not in the current ConsoleKit session,
+        // or screensaver is active, don't play sounds
+        if (!this.ckListener.sessionActive)
+            return;        
+
+        if (this._ssProxy.screenSaverActive)
+            return;
+
+        global.play_theme_sound(0, 'device-added-media');
+    },
+
+    _onDriveDisconnected: function() {
+        // if we're not in the current ConsoleKit session,
+        // or screensaver is active, don't play sounds
+        if (!this.ckListener.sessionActive)
+            return;        
+
+        if (this._ssProxy.screenSaverActive)
+            return;
+
+        global.play_theme_sound(0, 'device-removed-media');        
+    },
+
     _onVolumeAdded: function(monitor, volume) {
         this._checkAndMountVolume(volume);
     },